package com.liuyk.commonlib.network.request;

import java.util.HashMap;
import java.util.Map;

/**
 * 任意类型的参数
 * <p>
 * Created by liuyakui on 2020-02-20.
 */
public abstract class BaseTypeRequest<T> extends BaseRequest {

    //注意：builderTypeParams和builderParams只能同时实现一个
    public BaseTypeRequest(String url) {
        super(url);
    }

    //支持自定义类型
    public Map<String, T> getTypeParams() {
        final Map<String, T> params = new HashMap<>();
        final Map<String, T> builderParams = builderTypeParams();
        if (builderParams != null) {
            params.putAll(builderParams);
        }
        return params;
    }

    protected abstract Map<String, T> builderTypeParams();

    @Override
    public Map<String, String> builderParams() {
        return null;
    }
}
